﻿<template>
  <div class="app-container">
    <div class="filter-title">
      <el-form label-position="right" label-width="80px">
        <el-form-item :label="$t('location.name')+' :'">
          <el-input
            v-model="listQuery.name"
            style="width: 150px"
            class="filter-item"
            :placeholder="$t('location.name')"
            @keyup.enter.native="handleFilter"
          ></el-input>
        </el-form-item>
        <el-form-item :label="$t('location.region')+' :'">
          <el-input
            v-model="listQuery.region_name"
            style="width: 150px"
            class="filter-item"
            :placeholder="$t('location.region')"
            @keyup.enter.native="handleFilter"
          ></el-input>
        </el-form-item>
        <el-form-item :label="$t('public.status')+' :'">
          <el-select
            v-model="listQuery.status"
            clearable
            style="width: 150px"
            class="filter-item"
            :placeholder="$t('public.status')"
          >
            <el-option
              v-for="item in statusOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-button
          style="margin-left:20px"
          class="filter-item"
          type="primary"
          icon="el-icon-search"
          @click="handleFilter"
        >{{ $t('table.search') }}</el-button>
        <el-button
          v-if="permission.add"
          style="margin-left: 10px;float:right"
          class="filter-item"
          type="primary"
          icon="el-icon-edit"
          @click="handleCreate"
        >{{ $t('table.add') }}</el-button>
        <el-button
          style="margin-left: 10px"
          class="filter-item"
          type="primary"
          @click="handleRefresh"
        >{{ $t('table.refresh') }}</el-button>
      </el-form>
    </div>

    <div class="headAdd">
      <el-button
        v-for="item in sortList"
        :key="item.id"
        style="margin-left: 10px"
        class="filter-item"
        @click="locationFilter(item.id)"
      >{{ item.name }}</el-button>
      <span
        v-if="permission.addSort"
        style="margin-left: 10px;"
        class="filter-item"
        @click="handleSortCreate"
      >
        <i class="el-icon-circle-plus-outline"></i>
      </span>
    </div>
    <el-table
      :key="tableKey"
      v-loading="listLoading"
      :data="list"
      element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading"
      element-loading-background="rgba(255,255,255,0.2)"
      border
      fit
      highlight-current-row
      style="width: 100%min-height:1000px"
    >
      <el-table-column fixed="left" align="center" :label="$t('table.id')" width="65">
        <template slot-scope="scope">
          <span>{{ (listQuery.page-1)*listQuery.limit+scope.$index+1 }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('location.name')">
        <template slot-scope="scope">
          <span>{{ scope.row.name }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('location.classify')">
        <template slot-scope="scope">
          <span>{{ scope.row.classify_name }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('location.region')">
        <template slot-scope="scope">
          <span>{{ scope.row.region_name }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('public.charge')">
        <template slot-scope="scope">
          <span>{{ scope.row.charge }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('location.equipmentCount')">
        <template slot-scope="scope">
          <span>{{ scope.row.equipment_count }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('public.remark')">
        <template slot-scope="scope">
          <span>{{ scope.row.remark }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('public.status')">
        <template slot-scope="scope">
          <span
            :class="statusColorSecond(scope.row.status)"
          >{{ statusEstimation(scope.row.status) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        align="center"
        :label="$t('table.actions')"
        :width="operWidth"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="mini"
            @click="handleRead(scope.row)"
          >{{ $t('table.read') }}</el-button>
          <el-button
            v-if="scope.row.status === 2 && permission.review"
            type="danger"
            size="mini"
            :disabled="updateDisabled"
            @click="handleDisable(scope.row)"
          >{{ $t('table.disable') }}</el-button>
          <el-button
            v-else-if="scope.row.status === 4 && permission.review"
            type="success"
            size="mini"
            :disabled="enableDisable"
            @click="handleEnable(scope.row)"
          >{{ $t('table.enable') }}</el-button>
          <el-button
            v-if="permission.review && (scope.row.status === 1 || scope.row.status === 3) "
            type="primary"
            size="mini"
            @click="handleReview(scope.row)"
          >{{ $t('table.review') }}</el-button>
        </template>
      </el-table-column>
    </el-table>

    <div class="pagination-container">
      <el-pagination
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        :current-page="listQuery.page"
        :page-sizes="[10,20,30,50]"
        :page-size="listQuery.limit"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
      ></el-pagination>
    </div>
    <!-- 商圈分类编辑 -->
    <el-dialog title="添加" :visible.sync="sortDataFormVisible">
      <el-form
        ref="sortDataForm"
        :rules="sortRules"
        :model="sortTemp"
        label-position="right"
        label-width="35%"
        style="width: 400px margin:auto"
        size="small"
      >
        <el-form-item :label="$t('location.merchantCirclename')+' :'" prop="name">
          <el-input v-model="sortTemp.name"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="sortDataFormVisible = false">{{ $t('table.cancel') }}</el-button>
        <el-button
          type="primary"
          :disabled="createSortDisabled"
          @click="createSortData"
        >{{ $t('table.confirm') }}</el-button>
      </div>
    </el-dialog>
    <!-- 商圈编辑 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
      <el-form
        ref="dataForm"
        :rules="rules"
        :model="temp"
        label-position="right"
        label-width="35%"
        style="width: 400px margin:auto"
        size="small"
      >
        <el-form-item v-if="dialogStatus=='review'" :label="$t('location.name')+' :'">
          <span>{{ temp.name }}</span>
        </el-form-item>
        <el-form-item v-else :label="$t('location.name')+' :'" prop="name">
          <el-input v-model="temp.name"></el-input>
        </el-form-item>
        <el-form-item v-if="dialogStatus=='review'" :label="$t('location.classify')+' :'">
          <span>{{ getClassifyName(temp.classify_id) }}</span>
        </el-form-item>
        <el-form-item v-else :label="$t('location.classify')+' :'" prop="classify_id">
          <el-select v-model="temp.classify_id" placeholder="请选择">
            <el-option v-for="item in sortList" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="dialogStatus=='review'" :label="$t('location.region')+' :'">
          <span>{{ temp.region_name }}</span>
        </el-form-item>
        <el-form-item v-else :label="$t('location.region')+' :'" prop="region_id">
          <select-page
            :id="temp.region_id"
            :name="temp.region_name"
            style="width:200px"
            placeholder="请选择区域"
            :data="areaOptions"
            key-field="id"
            show-field="name"
            :count="areaCount"
            :page-size="pageSize"
            @getList="getAreaList"
            @values="getAreaid"
          ></select-page>
        </el-form-item>
        <el-form-item
          v-if="dialogStatus==='review' && temp.remark"
          :label="$t('public.remark')+' :'"
        >
          <span>{{ temp.remark }}</span>
        </el-form-item>
        <el-form-item
          v-if="dialogStatus!=='review'"
          :label="$t('public.remark')+' :'"
          prop="remark"
        >
          <el-input v-model="temp.remark" type="textarea"></el-input>
        </el-form-item>
        <el-form-item v-if="dialogStatus=='review'" :label="$t('public.charge')+' :'">
          <span>{{ temp.charge }}</span>
        </el-form-item>
        <el-form-item v-else :label="$t('public.charge')+' :'" prop="charge">
          <el-input-number v-model="temp.charge"></el-input-number>
        </el-form-item>
        <span
          v-if="dialogStatus!='review' || temp.special_time"
          class="information-title oneRow"
        >特殊时段设置:&nbsp;&nbsp;</span>
        <template v-if="dialogStatus!='review'">
          <time-select-input
            v-for="(item,index) in temptime"
            ref="childRules"
            :key="index"
            :start="item.start"
            :end="item.end"
            :value="item.value"
            :idx="index"
            @getTempTime="getTempTime"
            @reduceCount="reduceCount"
          ></time-select-input>
          <div>
            <div style="width:35%;display:inline-block"></div>
            <i class="el-icon-plus" @click="addDateTimeCount"></i>
          </div>
        </template>
        <el-form-item v-else-if="temp.special_time" :label="$t('location.specialTimeCharge')+' :'">
          <span>{{ specialTimeES(temp.special_time) }}</span>
        </el-form-item>
        <el-form-item v-if="dialogStatus=='review'" :label="$t('public.status')+' :'" prop="status">
          <el-radio-group v-model="temp.status">
            <el-radio :label="1" disabled>审核中</el-radio>
            <el-radio :label="2">审核通过</el-radio>
            <el-radio :label="3">未通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          v-if="dialogStatus=='review' && temp.status === 3"
          :label="$t('public.auditOpinion')+' :'"
          prop="check_remark"
        >
          <el-input v-model="temp.check_remark" type="textarea"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">{{ $t('table.cancel') }}</el-button>
        <el-button
          v-if="dialogStatus=='create'"
          type="primary"
          :disabled="createDisabled"
          @click="createData"
        >{{ $t('table.confirm') }}</el-button>
        <el-button
          v-else
          type="primary"
          :disabled="reviewDisabled"
          @click="reviewData"
        >{{ $t('table.confirm') }}</el-button>
      </div>
    </el-dialog>
    <!-- 查看 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormRead">
      <el-form
        :model="temp"
        label-position="right"
        label-width="40%"
        style="width: 400px margin-left:120px"
      >
        <el-form-item :label="$t('location.name')+' :'">
          <span>{{ temp.name }}</span>
        </el-form-item>
        <el-form-item :label="$t('location.classify')+' :'">
          <span>{{ temp.classify_name }}</span>
        </el-form-item>
        <el-form-item :label="$t('location.region')+' :'">
          <span>{{ temp.region_name }}</span>
        </el-form-item>
        <el-form-item v-if="temp.remark" :label="$t('public.remark')+' :'">
          <span>{{ temp.remark }}</span>
        </el-form-item>
        <el-form-item :label="$t('public.charge')+' :'">
          <span>{{ temp.charge }}</span>
        </el-form-item>
        <span v-if="temp.special_time" class="information-title oneRow">特殊时段设置:&nbsp;&nbsp;</span>
        <el-form-item v-if="temp.special_time" :label="$t('location.specialTimeCharge')+' :'">
          <span>{{ specialTimeES(temp.special_time) }}</span>
        </el-form-item>
        <el-form-item :label="$t('public.status')+' :'">
          <span>{{ statusEstimation(temp.status) }}</span>
        </el-form-item>
        <el-form-item v-if="temp.status === 3" :label="$t('public.auditOpinion')+' :'">
          <span>{{ temp.check_remark }}</span>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import TimeSelectInput from "@/views/select/TimeSelectInput"; // 引用时间组件
import selectPage from "@/views/select/SelectPage"; // 分页选择控件

export default {
  name: "Location",
  components: {
    "select-page": selectPage,
    "time-select-input": TimeSelectInput
  },
  data() {
    const charge = (rule, value, callback) => {
      if (value || value === 0) {
        if (value > 0 && value < 100) {
          callback();
        } else {
          callback(new Error("收费标准大于0小于100！"));
        }
      } else {
        callback(new Error("请填写收费标准！"));
      }
    };
    const positionName = (rule, value, callback) => {
      if (value) {
        if (value.length > 20) {
          callback(new Error("位置名称不得超过20个字符！"));
        } else {
          callback();
        }
      } else {
        callback(new Error("请填写位置名称！"));
      }
    };
    const remark = (rule, value, callback) => {
      if (value) {
        if (value.length > 150) {
          callback(new Error("备注信息不得超过150个字符！"));
        } else {
          callback();
        }
      } else {
        callback();
      }
    };
    const check_remark = (rule, value, callback) => {
      if (value) {
        if (value.length > 150) {
          callback(new Error("审核意见不得超过150个字符！"));
        } else {
          callback();
        }
      } else {
        callback(new Error("请填写审核意见！"));
      }
    };
    return {
      loading: false,
      tableKey: 0,
      list: null,
      total: null,
      listLoading: true,
      statusOptions: [
        {
          value: 1,
          label: "审核中"
        },
        {
          value: 2,
          label: "审核通过"
        },
        {
          value: 3,
          label: "未通过"
        },
        {
          value: 4,
          label: "禁用"
        }
      ],
      listQuery: {
        page: 1,
        limit: 20,
        name: "",
        region_name: "",
        classify_id: "",
        status: ""
      },
      temp: {
        id: undefined,
        name: "",
        classify_id: "",
        classify_name: "",
        region_id: "",
        region_name: "",
        remark: "",
        charge: undefined,
        status: "",
        check_remark: ""
      },
      sortTemp: {
        name: ""
      },
      sortDataFormVisible: false,
      dialogFormVisible: false,
      dialogFormRead: false,
      dialogStatus: "",
      textMap: {
        update: "更新",
        create: "添加",
        review: "审核",
        read: "查看"
      },
      rules: {
        name: [{ required: true, trigger: "blur", validator: positionName }],
        classify_id: [
          { required: true, message: "请填写位置类型", trigger: "change" }
        ],
        region_id: [
          { required: true, message: "请选择区域", trigger: "change" }
        ],
        remark: [{ trigger: "blur", validator: remark }],
        charge: [{ required: true, trigger: "blur", validator: charge }],
        status: [{ required: true, message: "请审核", trigger: "change" }],
        check_remark: [
          { required: true, trigger: "blur", validator: check_remark }
        ]
      },
      sortRules: {
        name: [{ required: true, message: "请填写商圈分类名", trigger: "blur" }]
      },
      createDisabled: false,
      enableDisable: false,
      updateDisabled: false,
      reviewDisabled: false,
      createSortDisabled: false,
      permission: {
        add: false,
        del: false,
        review: false
      },
      sortList: [],
      name: "",
      areaOptions: [],
      areaCount: undefined,
      pageSize: 20,
      temptime: [{ start: "", end: "", value: "" }]
    };
  },
  computed: {
    operWidth: function() {
      let itemCount = 1;
      if (this.permission.del) {
        itemCount += 1;
      }
      if (this.permission.update) {
        itemCount += 1;
      }
      if (this.permission.review) {
        itemCount += 1;
      }
      return itemCount * 80 + "px";
    }
  },
  created() {
    if (this.$store.state.permission.jurisdiction === "*") {
      this.permission.add = true;
      this.permission.review = true;
      this.permission.addSort = true;
    } else {
      const jurisdiction = this.$store.state.permission.jurisdiction.split(",");
      jurisdiction.forEach(element => {
        const id = parseInt(element);
        if (id === 219) {
          this.permission.add = true;
        } else if (id === 220) {
          this.permission.review = true;
        } else if (id === 222) {
          this.permission.addSort = true;
        }
      });
    }
    this.getList();
    this.getSort();
  },
  methods: {
    getTempTime(start, end, value, idx) {
      this.temptime[idx].start = start;
      this.temptime[idx].end = end;
      this.temptime[idx].value = value;
    },
    reduceCount(start, end, value, idx) {
      this.temptime.splice(idx, 1);
    },
    addDateTimeCount() {
      this.temptime.push({ start: "", end: "", value: "" });
    },
    getAreaList(pageNumber = 1, search = "") {
      this.getArea(pageNumber, search);
    },
    getAreaid(data) {
      if (data.length > 0) {
        this.temp.region_id = data[0].id;
        this.temp.region_name = data[0].name;
      } else {
        this.temp.region_id = undefined;
        this.temp.region_name = "";
      }
    },
    locationFilter(location) {
      this.listQuery.page = 1;
      this.listQuery.classify_id = location;
      this.getList();
    },
    handleFilter() {
      this.listQuery.page = 1;
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.limit = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.page = val;
      this.getList();
    },
    handleRefresh() {
      this.listQuery = {
        page: 1,
        limit: 20,
        name: "",
        region_name: "",
        classify_id: "",
        status: ""
      };
      this.getList();
    },
    handleSortCreate() {
      this.resetTemp();
      this.dialogStatus = "create";
      this.sortDataFormVisible = true;
      this.$nextTick(() => {
        this.$refs["sortDataForm"].clearValidate();
      });
    },
    handleCreate() {
      this.resetTemp();
      this.dialogStatus = "create";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    handleReview(row) {
      // 打开审核弹窗
      this.temp = Object.assign({}, row); // copy obj
      this.dialogStatus = "review";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    handleRead(row) {
      // 打开查看弹窗
      this.temp = Object.assign({}, row); // copy obj
      this.dialogStatus = "read";
      this.dialogFormRead = true;
    },
    resetTemp() {
      this.temp = {
        id: undefined,
        name: "",
        classify_id: "",
        classify_name: "",
        region_id: "",
        region_name: "",
        remark: "",
        charge: undefined,
        status: "",
        check_remark: ""
      };
      this.sortTemp = {
        name: ""
      };
    },
    getSort() {
      const getClassifyListPath = {
        // 获取商圈分类
        company: "STQ",
        api: "pc_MerchantCircle_getClassifyList",
        version: "1.0",
        data: {}
      };
      this.socketApi.sendSock(JSON.stringify(getClassifyListPath), res => {
        if (res) {
          this.socketData(res);
        }
      });
    },
    getList() {
      this.listLoading = true;
      const data = {
        rows: this.listQuery.limit,
        page: this.listQuery.page
      };
      if (this.listQuery.name) {
        data["name"] = this.listQuery.name;
      }
      if (this.listQuery.region_name) {
        data["region_name"] = this.listQuery.region_name;
      }
      if (this.listQuery.classify_id) {
        data["classify_id"] = this.listQuery.classify_id;
      }
      if (this.listQuery.status) {
        data["status"] = this.listQuery.status;
      }
      const merchantCircleIndexPath = {
        // 获取商圈列表
        company: "STQ",
        api: "pc_MerchantCircle_index",
        version: "1.0",
        data: data
      };
      this.socketApi.sendSock(JSON.stringify(merchantCircleIndexPath), res => {
        if (res) {
          this.socketData(res);
        }
      });
    },
    createSortData() {
      // 添加商圈分类

      this.$refs["sortDataForm"].validate(valid => {
        if (valid) {
          if (!this.createSortDisabled) {
            this.createSortDisabled = true;
            const data = {
              name: this.sortTemp.name
            };
            const merchantCircleSortAddPath = {
              company: "STQ",
              api: "pc_MerchantCircle_addClassify",
              version: "1.0",
              data: data
            };
            this.socketApi.sendSock(
              JSON.stringify(merchantCircleSortAddPath),
              res => {
                if (res) {
                  this.socketData(res);
                }
                setTimeout(() => {
                  this.createSortDisabled = false;
                }, 1000);
              }
            );
          }
        }
      });
    },
    createData() {
      // 添加商圈

      this.$refs["dataForm"].validate(valid => {
        let flag = true;
        this.$refs["childRules"].forEach(element => {
          if (element.validateForm() === false) {
            flag = false;
          }
        });
        if (valid && flag) {
          if (!this.createDisabled) {
            this.createDisabled = true;
            this.sortList.forEach(element => {
              if (element.id === this.temp.classify_id) {
                this.temp.classify_name = element.name;
              }
            });
            const data = {
              name: this.temp.name,
              classify_id: this.temp.classify_id,
              classify_name: this.temp.classify_name,
              region_id: this.temp.region_id,
              region_name: this.temp.region_name,
              remark: this.temp.remark,
              charge: this.temp.charge
            };

            const dataTime = [];
            this.temptime.forEach(element => {
              if (element.start && element.end) {
                dataTime.push(element);
              }
            });
            if (dataTime.length > 0) {
              data["special_time"] = dataTime;
            } else {
              data["special_time"] = "";
            }

            const merchantCircleAddPath = {
              company: "STQ",
              api: "pc_MerchantCircle_add",
              version: "1.0",
              data: data
            };
            this.socketApi.sendSock(
              JSON.stringify(merchantCircleAddPath),
              res => {
                if (res) {
                  this.socketData(res);
                }
                setTimeout(() => {
                  this.createDisabled = false;
                }, 1000);
              }
            );
          }
        }
      });
    },
    handleDisable(row) {
      if (!this.enableDisable) {
        this.enableDisable = true;
        const adEditPath = {
          company: "STQ",
          api: "pc_MerchantCircle_check",
          version: "1.0",
          data: {
            id: row.id,
            status: 4,
            returnType: "disable"
          }
        };
        this.socketApi.sendSock(JSON.stringify(adEditPath), res => {
          if (res) {
            this.socketData(res);
          } else {
            this.$message.error(" 启用失败 ");
          }
          setTimeout(() => {
            this.enableDisable = false;
          }, 1000);
        });
      }
    },
    handleEnable(row) {
      if (!this.updateDisabled) {
        this.updateDisabled = true;
        const adEditPath = {
          company: "STQ",
          api: "pc_MerchantCircle_check",
          version: "1.0",
          data: {
            id: row.id,
            status: 2,
            returnType: "enable"
          }
        };
        this.socketApi.sendSock(JSON.stringify(adEditPath), res => {
          if (res) {
            this.socketData(res);
          } else {
            this.$message.error(" 禁用失败 ");
          }
          setTimeout(() => {
            this.updateDisabled = false;
          }, 1000);
        });
      }
    },
    reviewData() {
      // 审核商圈信息
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          if (!this.reviewDisabled) {
            this.reviewDisabled = true;
            const data = {
              id: this.temp.id,
              status: this.temp.status,
              check_remark: this.temp.check_remark
            };
            data["returnType"] = "review";
            const merchantCircleCheckPath = {
              company: "STQ",
              api: "pc_MerchantCircle_check",
              version: "1.0",
              data: data
            };
            this.socketApi.sendSock(
              JSON.stringify(merchantCircleCheckPath),
              res => {
                if (res) {
                  this.socketData(res);
                }
                setTimeout(() => {
                  this.reviewDisabled = false;
                }, 1000);
              }
            );
          }
        }
      });
    },
    getArea(pageNumber, search) {
      const areaIndexPath = {
        company: "STQ",
        api: "pc_region_index",
        version: "1.0",
        data: {
          name: search,
          page: pageNumber,
          rows: this.pageSize
        }
      };
      this.socketApi.sendSock(JSON.stringify(areaIndexPath), res => {
        if (res) {
          this.socketData(res);
        }
      });
    },
    socketData(res) {
      if (res !== '{"type":"ping"}') {
        const resj = JSON.parse(res);
        if (resj.code === -1) {
          this.$message.error(resj.message);
        } else {
          if (resj.api === "pc_MerchantCircle_index") {
            this.total = resj.count;
            this.list = resj.data;
            this.listLoading = false;
          } else if (resj.api === "pc_MerchantCircle_addClassify") {
            this.sortDataFormVisible = false;
            this.getSort();
            this.$notify({
              title: "成功",
              message: "添加成功",
              type: "success",
              duration: 2000
            });
          } else if (resj.api === "pc_MerchantCircle_getClassifyList") {
            this.sortList = resj.data;
          } else if (resj.api === "pc_region_index") {
            const options = [];
            resj.data.forEach(element => {
              options.push({ id: element.id, name: element.region_name });
            });
            this.areaOptions = options;
            this.areaCount = resj.count;
          } else if (resj.api === "pc_MerchantCircle_add") {
            this.dialogFormVisible = false;
            this.getList();
            this.$notify({
              title: "成功",
              message: "添加成功",
              type: "success",
              duration: 2000
            });
          } else if (
            resj.api === "pc_MerchantCircle_check" &&
            resj.type === "review"
          ) {
            this.dialogFormVisible = false;
            this.getList();
            this.$notify({
              title: "成功",
              message: "审核成功",
              type: "success",
              duration: 2000
            });
          } else if (
            resj.api === "pc_MerchantCircle_check" &&
            resj.type === "enable"
          ) {
            this.getList();
            this.$notify({
              title: "成功",
              message: "启用成功",
              type: "success",
              duration: 2000
            });
          } else if (
            resj.api === "pc_MerchantCircle_check" &&
            resj.type === "disable"
          ) {
            this.getList();
            this.$notify({
              title: "成功",
              message: "禁用成功",
              type: "success",
              duration: 2000
            });
          }
        }
      }
    },
    specialTimeES(specialTime) {
      const time = [];
      specialTime.forEach(elemet => {
        time.push(
          "时间段：" +
            elemet.start +
            "-" +
            elemet.end +
            " 收费：" +
            elemet.value
        );
      });
      return time.join(",");
    },
    getClassifyName(type) {
      let classifyName = "";
      this.sortList.forEach(element => {
        if (element.id === type) {
          classifyName = element.name;
        }
      });
      return classifyName;
    }
  }
};
</script>
